from selenium.webdriver.common.by import By

from common.Utils import ForumDriver


class ForumPartition:
    url=""
    driver=""
    def __init__(self):
        self.url="http://127.0.0.1:58080/index.html"
        self.driver=ForumDriver.driver
        self.driver.get(self.url)
    #JAVA分区
    def Partition1(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(2) > a").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "JAVA"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #C++分区
    def Partition2(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(3) > a").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "C++"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #前端分区
    def Partition3(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(4) > a > span.nav-link-title").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "前端"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #MySQL分区
    def Partition4(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(5) > a > span.nav-link-title").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "MySql"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #面试分区
    def Partition5(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(6) > a > span.nav-link-title").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "面试"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #经验分区
    def Partition6(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(7) > a > span.nav-link-title").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "经验"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #招聘分区
    def Partition7(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(8) > a > span.nav-link-title").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "招聘"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #福利分区
    def Partition8(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(9) > a").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "福利"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()

    #灌水分区
    def Partition9(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(10) > a > span.nav-link-title").click()
        actual=self.driver.find_element(By.CSS_SELECTOR, "#artical-items-body > div > div > div.col > div.text-truncate > a > strong").text
        print(actual)
        assert actual == "水货"
        # 返回首页
        self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a").click()